package com.yunhe.rentcars.pro.service.rent.impl;

import com.yunhe.rentcars.commons.dto.Pageable;
import com.yunhe.rentcars.pro.dao.rent.YuDingCarDao;
import com.yunhe.rentcars.pro.entity.rent.CarOrder;
import com.yunhe.rentcars.pro.service.rent.YuDingCarService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * Created by Administrator on 2017/12/1 0001.
 */
@Service
public class YuDingCarServiceImpl implements YuDingCarService {

    @Autowired
    private YuDingCarDao yuDingCarDao;

    @Override
    public Pageable<CarOrder> findYuDingCarOrderList(Integer offset, Integer limit, String orderid, String mobile) {
        int yuDingCarCount = yuDingCarDao.findYuDingCarOrderCount(orderid, mobile);
        List<CarOrder> yuDingCarList = null;
        if(yuDingCarCount>0){
            yuDingCarList = yuDingCarDao.findYuDingCarOrderList(offset, limit, orderid, mobile);
        }
        Pageable<CarOrder> pageable = new Pageable<>();
        pageable.setTotal(yuDingCarCount);
        pageable.setRows(yuDingCarList);
        return pageable;
    }

    @Override
    public CarOrder findYuDingCarOrder(Long id) {
        CarOrder yuDingCarOrder = yuDingCarDao.findYuDingCarOrder(id);
        return yuDingCarOrder;
    }
}
